package com.yf.ability.login.cropwechat.service.impl;


import com.yf.ability.login.cropwechat.dto.response.DetailRespDTO;
import com.yf.ability.login.cropwechat.dto.response.InfoRespDTO;
import com.yf.ability.login.cropwechat.service.CropWechatLoginService;
import com.yf.ability.login.cropwechat.utils.CropWechatUtils;
import com.yf.ability.shiro.dto.SysUserLoginDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 微信登录业务类
 * @author bool
 */
@Service
public class CropWechatLoginServiceImpl implements CropWechatLoginService {


    @Override
    public InfoRespDTO login(String cropId, String cropSecret, String code, String nickName, String avatar) {
        String access = CropWechatUtils.requestAccess(cropId, cropSecret);
        InfoRespDTO resp = CropWechatUtils.requestInfo(access, code);
        // 登录并返回
        return resp;
    }

    @Override
    public DetailRespDTO webLogin(String cropId, String cropSecret, String code) {
        // 转换为登录结果
        DetailRespDTO resp = CropWechatUtils.requestLogin(cropId, cropSecret, code);
        return resp;
    }
}
